import { createApp } from "vue";
import App from "./App.vue";
import router from "./router/index.js";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import ElementPlus from "element-plus";
import { gotoDetail, gotoList, gotoRouter } from "./utils/action";
import "normalize.css";
import "animate.css";
import "bulma/css/bulma.css";
import "element-plus/dist/index.css";
import "font-awesome/css/font-awesome.css";
import { ElMessageBox } from "element-plus";
import axios from "axios";
window.axios = axios;
const app = createApp(App);

app.config.globalProperties.gotoDetail = gotoDetail;
app.config.globalProperties.gotoList = gotoList;
app.config.globalProperties.gotoRouter = gotoRouter;
app.config.globalProperties.downloadUrl = (url,id,openUrl) => {
  if (url) {
    window.axios.get('/api/download/common/visitPage/'+window.btoa(id+'_'+url)+'.html')
    window.open(url);
  } else {
    ElMessageBox.alert("未获取到下载地址！", "提示", {
      type: "warning",
      "confirm-button-text": "确定",
    });
  }
  if(openUrl){
    window.open(openUrl,'_blank');
  }
};

export default app
  .use(ElementPlus, { size: "mini", zIndex: 3000, locale: zhCn })
  .use(router)
  .mount("#app");
